#pragma once

#include <map>
#include "Pointer.h"
#include "HashedString.h"
#include "IMessenger.h"
#include "TinyXML2.h"

class Entity;

class IComponent : public IMessenger
{
public:
	typedef Pointer<IComponent>(*Creator)( std::string&, Entity* );

	typedef std::map<const HashedString, Creator> CreatorMap_t;
	typedef std::pair<const HashedString, Creator> CreatorPair_t;
	typedef std::map<const HashedString, Pointer<IComponent>> Map_t;
	typedef std::pair<const HashedString, Pointer<IComponent>> Pair_t;
	
	IComponent( Entity* parent );
	IComponent( IComponent& o );
	virtual ~IComponent(){};

	virtual const HashedString& Type() = 0;
	virtual std::string ToString() const = 0;
	virtual bool ToXML( tinyxml2::XMLPrinter& printer ) = 0;
	virtual void Remove( ) {};
	virtual void ReceiveMessage( IMessage* message ) {};
	Entity* Parent();
protected:
	Entity* m_parent;
};